/*
 * accel functions
 *
 */

#ifndef ACCEL_H_
#define ACCEL_H_
#include "config.h" 

#ifndef CONFIG_WITH_ACCEL_I2C

//
//adjust accel value 
// Those analogues values set the 0 as 1.62V. 
#define adjx   8
#define adjy  20
#define adjz -20

// value of 0g in volt, 10bits representation for 5V, and 5/1024
#define vzero 1.62
#define dzero 331
#define vbit 0.00489

// gyro datasheet, here LPR503 8.3mv/°s, LPR530 0.83mv/°s
// 4.89mv / 8.3mv = 0.58915/°s => 1,6973 °s
#define LPR503_SENS 1,6983
#define LPR530_SENS 16.9834
//#define LPR530_SENS 0.169

#endif

#define r2deg 57.2957795
#define orthogonal 1.5707963

#ifdef __cplusplus
extern "C"{
#endif

void accel_init();

#ifndef CONFIG_WITH_ACCEL_I2C
//
//get G from Volt
//
double VToG(float volt);

//
//get volt from ADC
//
float adcToV(double adc);

#endif

//
//
// update vector values for 
//   angles a[x,y,z] 
//   coordinates v[x,y,z], 
//   coordinates after rotation v1[x,y,z], 
//   force in newton for 60kg mass n[x,y,z], 
//   input vref value
int accel_update(double*, double*, double*, double*, double vref, double mass);


#ifdef __cplusplus
}
#endif
#endif

